package com.yanqu.road.server.channelserver.cmd.activity.washe.friend;

import com.yanqu.road.entity.activity.washe.data.WasheUserKey;
import com.yanqu.road.logic.pb.WashePb2;
import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.pb.activity.WasheProto;
import com.yanqu.road.server.channelserver.cmd.ChannelCommand;
import com.yanqu.road.server.channelserver.manager.activity.washe.ChannelWasheActivity;
import com.yanqu.road.server.channelserver.manager.activity.washe.ChannelWasheMgr;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.protocol.ChannelProtocol;

@Cmd(code = ChannelProtocol.N_WASHE_FRIEND_IN_ROOM_OPERATE, desc = "")
public class ChannelWasheFriendInRoomOperateCmd extends ChannelCommand {

    @Override
    public boolean parseData(YanQuMessage packet) throws Exception {
        WasheProto.ChannelWasheFriendInRoomOperateReqMsg reqMsg = WasheProto.ChannelWasheFriendInRoomOperateReqMsg.parseFrom(packet.getBytes());
        WasheUserKey userKey = WashePb2.parseWasheUserKey(reqMsg.getUserKey());

        ChannelWasheActivity activity = ChannelWasheMgr.getActivity(userKey.getChannelId());
        if (activity == null) {
            log.error("can not find washe activity! channelId {}.", userKey.getChannelId());
            return true;
        }

        int type = reqMsg.getType();
        if (type == 1) {
            activity.friendReadyByCmd(userKey, reqMsg.getReady());
        } else if (type == 2) {
            activity.friendQuickChatByCmd(userKey, reqMsg.getQuickChatId());
        } else if (type == 3) {
            activity.friendChangeCardByCmd(userKey, reqMsg.getChangeCardId(), reqMsg.getSkillIdListList());
        } else if (type == 4) {
            activity.friendChangeSceneByCmd(userKey, reqMsg.getChangeSceneId());
        }

        return true;
    }

    @Override
    public void execute(YanQuMessage packet) throws Exception {

    }

    @Override
    public void sendData() {

    }
}
